package com.kedacom.ctsp.authz.security.checker;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.security.core.SpringSecurityMessageSource;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * 默认的用户前置检查
 *
 * @author xuwei
 * @create 2017-11-30 11:16
 **/
@Slf4j
public class DefaultPreAuthenticationChecks implements PreAuthenticationChecker {

    protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();

    @Override
    public void check(UserDetails user) {
        // TODO
//        if (!user.isAccountNonLocked()) {
//            log.debug("User account is locked");
//
//            throw new LockedException(messages.getMessage(
//                    "AbstractUserDetailsAuthenticationProvider.locked",
//                    "User account is locked"));
//        }
//
//        if (!user.isEnabled()) {
//            log.debug("User account is disabled");
//
//            throw new DisabledException(messages.getMessage(
//                    "AbstractUserDetailsAuthenticationProvider.disabled",
//                    "User is disabled"));
//        }
//
//        if (!user.isAccountNonExpired()) {
//            log.debug("User account is expired");
//
//            throw new AccountExpiredException(messages.getMessage(
//                    "AbstractUserDetailsAuthenticationProvider.expired",
//                    "User account has expired"));
//        }
    }
}
